<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../vue.js"></script>
</head>

<body>
  <div id="app">
    <button @click="isSaving = !isSaving">切换保存和编辑按钮</button>
    <div>
      <transition name="fade">// 使用v-bind指令绑定key属性

        <button :key="isSaving">{{isSaving ? "Save" : "Edit"}}</button>
      </transition>
    </div>
  </div>

  <script>
    var vm = new Vue({
      el: "#app",
      data: {
        isSaving: true, // isSaving为true，显示保存按钮，为false显示编辑按钮
      }
    })
  </script>
</body>

</html>